CC = gcc
CFLAGS = -g -Wall
LIB = /usr/lib/libssock.a
SOURCES = $(OBJECTS, o/=src/)
HEADERS = h/ssock_tcpsock.h h/ssock_udpsock.h h/ssock_system.h h/ssock.h
OBJECTS = o/ssock_udpsock.o o/ssock_tcpsock.o

headers:
	mkdir -p /usr/include/ssock
	cp -r h/* /usr/include/ssock/

o/%.o: src/%.c $(HEADERS) headers
	$(CC) $(CFLAGS) $< -c -o $@

$(LIB): $(OBJECTS)
	ar rvs /usr/lib/libssock.a $(OBJECTS)
	
install: $(LIB)

clean:
	rm -rf o/* src/*~ h/*~ doc/*~ doc/*.aux doc/*.toc doc/*.log *~

.c.o :
	$(CC) $(CFLAGS) -c

.PHONY: headers install build 
